package com.module.compose.base

import android.annotation.SuppressLint
import android.app.Activity
import android.app.Application
import android.content.Context
import android.os.Bundle
import com.module.compose.base.utils.ToastUtils
import com.study.lib_tiandi_map.tiandimap.MapView
import com.study.zrouter.ZRouter

open class App : Application() {

    companion object {
        @SuppressLint("StaticFieldLeak")
        private lateinit var context: Context
        fun getContext(): Context = context
    }

    override fun onCreate() {
        super.onCreate()
        context = this
        //初始化天地图
        MapView.Companion.setDevKey("7558502e30c250cb0d46324f4d64b976")
        //toast注册
        ToastUtils.initToast(this)
        //路由初始化
        ZRouter.instance().init(this)

        //注册所有activity生命周期的监听
        registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
            override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
            }

            override fun onActivityStarted(activity: Activity) {
            }

            override fun onActivityResumed(activity: Activity) {
            }

            override fun onActivityPaused(activity: Activity) {
            }

            override fun onActivityStopped(activity: Activity) {
            }

            override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
            }

            override fun onActivityDestroyed(activity: Activity) {
            }
        })
    }
}